package com.dragon.refect.bytecode;

/**
 * 方法静态分派演示:
 *
 * 所有依赖静态类型来定位方法之行版本的分派动作称为静态分派。静态分派的典型应用是方法的重载
 *
 *
 * @author dragon
 * @since 2019/12/12
 */
public class StaticDispatch {

    static abstract class Human {

    }

    static class Man extends Human {

    }

    static class Woman extends Human {

    }

    public void sayHello(Human guy) {
        System.out.println("hello guy!");
    }

    public void sayHello(Man guy) {
        System.out.println("hello, gentleman!");
    }

    public void sayHello(Woman guy) {
        System.out.println("hello, lady!");
    }

    public static void main(String[] args) {
        Human man = new Man();
        Human woman = new Woman();
        StaticDispatch staticDispatch = new StaticDispatch();
        staticDispatch.sayHello(man);
        staticDispatch.sayHello(woman);
    }

}
